<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class M_data_kendaraan extends CI_Model {
	
    function __construct()
    {
        parent::__construct();
    }
    
	function input_data_kendaraan()
	{      
		$data = array(
                'user_id'           => '1',
                'Nama_Kesayangan'   => $this->input->post("namakesayangan"),
                'Jenis_VW'          => $this->input->post("jenisvw"),
                'Tahun_Produksi'    => $this->input->post("tahunproduksi"),
                'Nomor_Rangka'      => $this->input->post("norangka"),
                'Nomor_Plat'        => $this->input->post("noplat"),
                'Nomor_Lambung'     => $this->input->post("nolambung"),
                'Nomor_KTA'         => $this->input->post("nokta")
                );
		return $this->db->insert("data_kendaraan",$data);
	}
    
    function get_id_data_kendaraan($id ='')
    {
        $this->db->select('*');
        $this->db->from('data_kendaraan');
        $this->db->join('frum_meta','frum_meta.user_id = data_kendaraan.user_id');
        $this->db->where('Nomor_Plat', str_replace('%20',' ', $id));
        $params = $this->db->get();
        return $params->row();
    }
    
    function edit_data_kendaraan($id ='')
    {
        $id = $this->input->post('nomorplat');
        $edit_data =    array(
                        'Nama_Kesayangan'   => $this->input->post("namakesayangan"),
                        'Jenis_VW'          => $this->input->post("jenisvw"),
                        'Tahun_Produksi'    => $this->input->post("tahunproduksi"),
                        'Nomor_Rangka'      => $this->input->post("nomorrangka"),
                        'Nomor_Lambung'     => $this->input->post("nomorlambung"),
                        'Nomor_KTA'         => $this->input->post("nomorkta")
                        );
        $this->db->where('Nomor_Plat',$id);
        $this->db->update('data_kendaraan',$edit_data);
    }
    
    function get_data_kendaraan()
    {
        $this->db->select('*');
        $this->db->from('data_kendaraan');
        $this->db->join('frum_meta','frum_meta.user_id = data_kendaraan.user_id');
        $params = $this->db->get();
        return $params->result();
    }
}